﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace MyDay.Models
{
    public class Todo
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The subject must be at least 3 characters long.", MinimumLength = 3)]
        [DataType(DataType.Text)]
        [Display(Name = "Subject")]
        public string Subject { get; set; }

        [DataType(DataType.Date)]
        [Display(Name = "Due Date")]
        public DateTime DueDate { get; set; }

        [Display(Name = "Complete?")]
        public bool IsComplete { get; set; }

        // Foreign key to UserProfile in Membership Services
        [ForeignKey("UserProfile")]
        public int UserId { get; set; }
        public virtual UserProfile UserProfile { get; set; }



        public class TodosContext : DbContext
        {
            public TodosContext()
                : base("MyDayDB")
            {
            }

            public DbSet<Todo> Todos { get; set; }

            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Entity<Todo>().ToTable("Todos");
            }

        }

    }
}